package com.orphan.audit.service.impl;

import com.orphan.audit.po.PreDiscount;
import com.orphan.audit.dao.PreDiscountMapper;
import com.orphan.audit.service.IPreDiscountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wdn
 * @since 2021-07-16
 */
@Service
public class PreDiscountServiceImpl extends ServiceImpl<PreDiscountMapper, PreDiscount> implements IPreDiscountService {

    @Resource
    PreDiscountMapper preDiscountMapper;
    @Override
    public float getRate(float tMoney) {
        int money = (int)tMoney/1000;
        if(money == 0 || money == 1){
            money = 1;
            return preDiscountMapper.getRate(1);
        }else if(money >= 5){
            return preDiscountMapper.getRate(5);
        }
        return preDiscountMapper.getRate(money);
    }
}
